﻿using BackData;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Server.API.Application.Command.DeepProcess;
using Server.API.DTOs;

namespace Server.API.Controllers
{
    /// <summary>
    /// 深加工控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DDeepProcesssController : ControllerBase
    {
        IMediator mediator;

        public DDeepProcesssController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取深加工详情
        /// </summary>
        /// <param name="request">深加工主键</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>深加工信息</returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<APIResult<DeepProcessDTO>> GetDeepProcess([FromQuery] GetDeepProcessCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 深加工修改
        /// </summary>
        /// <param name="request">参数</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>影响行数</returns>
        [HttpPut]
        public async Task<APIResult<int>> Handle(UpdateDeepProcessCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
